_ = require 'underscore'
Article = require('./mongo_client').Article


noop = () ->

save = (data, cbf) ->
  cbf = cbf || noop
  if verify data, cbf
    new Article(data).save (err) ->
      cbf err
findAll = (cbf) ->
  cbf = cbf || noop
  Article.find {}, cbf
verify = (data, cbf) ->
  if _.isObject(data)
    return true
  else
    cbf new Error 'the save data is not a objcet' 
    return false

module.exports = 
  save : save
  findAll : findAll
